<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-btn+.layui-btn{
            margin-left: 0;
        }
        .layui-table td, .layui-table th
        {
            min-width: 50px !important;
        }
    </style>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>{$nav}</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3" style="line-height:30px"></i></a>
    </div>
    <div class="x-body x-admin">
        <fieldset class="layui-elem-field">
          <legend>分账数据</legend>
          <div class="layui-field-box" style="font-size: 15px;">
            可分账订单数：<span id="data-unc">加载中</span>　
            可分账订单总额：<span id="data-una1">加载中</span>元　
            可分账金额：<span id="data-una2">加载中</span>元　
            <button type="button" class="layui-btn layui-btn-normal" id="do_btn">全部分账1111</button>
            <br>
            已分账订单数：<span id="data-c">加载中</span>　
            已分账订单总额：<span id="data-a1">加载中</span>元　
            已分账金额：<span id="data-a2">加载中</span>元
          </div>
        </fieldset>
        <xblock style="display: flex;">
        
            <div class="layui-card-body" style="padding-left: 0;float:left;padding-left:20px;padding-top:0;">
              <form class="layui-form layui-col-space5" action="" method="get">
                <div class="layui-inline layui-show-xs-block">
                    <input style="width:260px;" type="text" name="keyword" id="keyword" value="{:input()['keyword']}" placeholder="活动/小程序" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-inline layui-show-xs-block">
                    <select name="status" >
                        <option value="">全部</option>
                        <option value="0" {:input()['status']=='0'?'selected':''}>待分账</option>
                        <option value="1" {:input()['status']=='1'?'selected':''}>已分账</option>
                    </select>
                </div>
                <input type="hidden" name="pay_uniacid" value="{:input('pay_uniacid')}">
                <div class="layui-inline layui-show-xs-block">
                  <button class="layui-btn" id="search-btn">搜索</button>
                </div>
              </form>
            </div>
        </xblock>
        <div class="layui-table-body layui-table-main" style="width: 100%;min-height:0;">
            <table class="layui-table layui-form" lay-filter="dataTable" id="dataTable"> </table>
        </div>

    </div>
    <script>
      layui.use(['form','layer','jquery','table','util'], function(){
        form = layui.form,
        layer = layui.layer
        ,$ = layui.jquery
        ,table = layui.table
        ,util = layui.util;
        
        $('#do_btn').click(function(){
            layer.confirm('是否全部提现?', {
                btn: ['确定','取消'] 
            }, function(){
                const loading = layer.load(1, {shade: [0.5,'#ccc'] });
                $.getJSON('doProfitSharingNew?pay_uniacid={:input('pay_uniacid')}',function(data){
                    if(data.code == 1)
                    {
                        layer.close(loading);
                        layer.alert('订单分账成功'+data.successCount+'条，一共'+data.totalCount+'条', {closeBtn: 0}, function(){
                            window.location.reload();
                        });
                    }
                },'json');
            }, function(){
            
            });
        })
        
        $.getJSON('profitSharingGetMchDataNew?pay_uniacid={:input('pay_uniacid')}',function(data){
            if(data.code == 1)
            {
                $('#data-unc').html(data.unProfitSharing.c);
                $('#data-una1').html(data.unProfitSharing.a1/100);
                $('#data-una2').html(data.unProfitSharing.a2/100);
                $('#data-c').html(data.profitSharing.c);
                $('#data-a1').html(data.profitSharing.a1/100);
                $('#data-a2').html(data.profitSharing.a2/100);
            }
        },'json')
        
          table.render({
            elem: '#dataTable'
            ,url:'profitSharingOrderListNew?pay_uniacid={:input()['pay_uniacid']}&keyword={:input()['keyword']}&status={:input()['status']}'
            //,toolbar: '#toolbarDemo' 
            //,defaultToolbar: ['filter', 'exports', 'print']
            ,limit: 20
            ,title: '分账订单'
            ,cols: [[
              {field:'status_text', width:100,title:"分账状态"},
              {field:'title',  title:"活动"},
              {field:'wxapp_name',width:100, title:"付款小程序"},
              {field:'order_amount', width:80,title:"订单金额"},
              {field:'sharing_amount', width:80,title:"分账金额"},
              {field:'openid', width:240,title:"分账openid"},
              {field:'creat_time', width:130,title:"订单时间"},
              {field:'finish_time', width:130,title:"分账时间"},
              {field:'transaction_id', width:100,title:"微信订单号"},
              {field:'order_id', width:100,title:"分账订单号"},
            ]]
            ,page: true
          });

        
      });

    </script>
  </body>

</html>